package ua.kratik.seabattle.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.springframework.format.annotation.DateTimeFormat;

import ua.kratik.seabattle.dao.DataObject;

@Entity
@Table (name = "admirals")
	@UniqueConstraint(columnNames = "email")
public class User implements DataObject{
	
	@Id
	@GeneratedValue
	@Column (name = "id")
	private Integer id;
	
	@Column (name  = "name")
	private String name;
	
	@Column (name = "surname")
	private String surname;
	
	@ManyToOne (fetch = FetchType.LAZY)
	@JoinColumn (name = "country_id", nullable = false)
	private Country country;
	
	@Column (name = "birthsday")
	@DateTimeFormat(pattern = "yyyy-mm-dd")
	private Date birthsday;
	
	@Column (name = "email")
	private String email;
	
	@Column (name = "pass")
	private String password;
	
	@GeneratedValue
	@Column (name = "registered")
	private Date registered;
	
//	//DEPENDENT
//	@OneToMany(fetch = FetchType.LAZY, mappedBy = ShipLayout.FK_USER)
//	private List<ShipLayout> shipLayouts;

	//GETTERS SETTERS
	public Integer getId() {
		return id;
	}

	@SuppressWarnings("unused")
	private void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Country getCountry() {
		return country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public Date getBirthsday() {
		return birthsday;
	}

	public void setBirthsday(Date birthsday) {
		this.birthsday = birthsday;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Date getRegistered() {
		return registered;
	}

	@SuppressWarnings("unused")
	private void setRegistered(Date registered) {
		this.registered = registered;
	}

//	public List<ShipLayout> getShipLayouts() {
//		return shipLayouts;
//	}
//
//	public void setShipLayouts(List<ShipLayout> shipLayouts) {
//		this.shipLayouts = shipLayouts;
//	}
	
}
